package com.jiangjiang.eshop.cart.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jiangjiang.eshop.cart.domain.ShoppingCartEntity;
import com.jiangjiang.eshop.cart.mapper.ShoppingCartMapper;
import org.springframework.stereotype.Service;

/**
 * @ClassName ShoppingCartService
 * @Description 购物车service
 * @Author jhw
 * @Date 2021/6/1 22:41
 * @Version 1.0
 **/

@Service
public class ShoppingCartService  extends ServiceImpl<ShoppingCartMapper, ShoppingCartEntity> {

    /**
     * 根据用户账户id查询购物车数据
     * @param userAccountId 用户账户
     * @return 购物车实体
     */
    public ShoppingCartEntity getShoppingCartByUserAccountId(Long userAccountId){
        LambdaQueryWrapper<ShoppingCartEntity> wrapper = Wrappers.<ShoppingCartEntity>lambdaQuery()
                .eq(ShoppingCartEntity::getUserAccountId, userAccountId);
        return this.getOne(wrapper);
    }


}
